<?php

namespace app\common\traits;

use app\common\model\Area;

trait AreaAssociatePart
{
    protected $provinceColumn = 'province_code';
    protected $cityColumn = 'city_code';
    protected $areaColumn = 'area_code';

    public function province()
    {
        return $this->hasOne(Area::class, 'code', $this->provinceColumn);
    }

    public function city()
    {
        return $this->hasOne(Area::class, 'code', $this->cityColumn);
    }

    public function area()
    {
        return $this->hasOne(Area::class, 'code', $this->areaColumn);
    }
}